// 导入请求接口
import { getCategoryListAPI } from '@/api/home'
const state = () => {
  return {
    // 分类商品列表
    categoryList: []
  }
}

const mutations = {
  setCategoryList: (state, newList) => {
    state.categoryList = newList
  }
}
const actions = {
  setCategoryListAction: async ({ commit }) => {
    // 调接口、发请求
    const res = await getCategoryListAPI()
    // 提交mutation
    commit('setCategoryList', res.result)
    // 组件只需要触发这个action函数即可
  }
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
